----------------
--TALENT CHECK--
----------------

if not TalentCheck then
	function TalentCheck(a)
		local b = { GetTalentInfo(a) }
		if b[5] ~= true then
			for i = 1, GetNumTalents() do
				local c = { GetTalentInfo(i) }
				if b[3] == c[3] and c[5] == true then
					local level = UnitLevel("player")
					local clear = level >= 86 and 79249
							or level >= 81 and 63388
							or level >= 15 and 64670
					if GetItemCount(clear) > 0 then
						RemoveTalent(i)
					else
						PQR_WriteToChat("Current talent(s) not supported.", "ERROR")
						PQR_StopRotation()
					end
				else
					LearnTalent(a)
				end
			end
		end
	end
else
	if UnitLevel("player") < GHOST_PlayerLevel then
		PQR_WriteToChat("Current level not supported.", "ERROR")
		PQR_StopRotation()
	end
	if GetSpecialization() ~= GHOST_PlayerSpec then
		PQR_WriteToChat("Profile specialization not active.", "ERROR")
		PQR_StopRotation()
	else
		if not interval then
			interval = GetTime()
		end
		if GetTime() - interval > 1
				and not UnitAffectingCombat("player") then
			interval = GetTime()
			for i = 1, #GHOST_TalentReq do
				TalentCheck(GHOST_TalentReq[i])
			end
		end
	end
end